<template>
	<u-tabbar v-model="current" :list="list" :mid-button="false" :border-top="false" :before-switch='beforeSwitch'></u-tabbar>
</template>

<script>
	let timer;
	export default {
		watch: {
			globalUnreadNum: {
				handler(val) {
					console.log(val)
					this.list[2].count = val;
				}
			}
		},
		data() {
			return {
				current: 0,
				list: [{
					iconPath: '/static/image/tabbar/home.png',
					selectedIconPath: '/static/image/tabbar/home-hl.png',
					text: '首页',
					pagePath: '/pages/home/home'
				}, {
					iconPath: '/static/image/tabbar/consult.png',
					selectedIconPath: '/static/image/tabbar/consult-hl.png',
					text: '快速咨询',
					pagePath: '/pages/consult/consult'
				},{
					iconPath: '/static/image/tabbar/session.png',
					selectedIconPath: '/static/image/tabbar/session-hl.png',
					text: '会话列表',
					pagePath: '/pages/session_list/sessionList',
					count:0,
				}, {
					iconPath: '/static/image/tabbar/profile.png',
					selectedIconPath: '/static/image/tabbar/profile-hl.png',
					text: '个人中心',
					pagePath: '/pages/profile/profile'
				}],
			}
		},
		methods: {
			beforeSwitch(index) {
				console.log("1")
				if (index == 2) {
					this.tapCount++;
					if(this.tapCount>=2){
						console.log('触发了双击')
						this.tapCount = 0;
						uni.$emit('doubleTap');
					}
					clearTimeout(timer);
					timer = setTimeout(() => {
						this.tapCount = 0;
					}, 500)
				}
				return true
			}
		}
	}
</script>

<style>
</style>
